package com.eliza.base.views.device.camera

import android.Manifest
import android.content.pm.PackageManager
import android.util.Log
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.core.content.ContextCompat

object CameraX {
    @Composable
    fun Show() {
        val current = LocalContext.current
        val result =
            rememberLauncherForActivityResult(ActivityResultContracts.RequestPermission()) { it ->
                if (it) {
                    Log.e("CameraX", "Show:RequestPermission $it")
                } else {
                    Log.e("CameraX", "Show:RequestPermission $it")
                }

            }
        when (PackageManager.PERMISSION_GRANTED) {
            ContextCompat.checkSelfPermission(
                current,
                Manifest.permission.CAMERA
            ) -> {
                Log.e("CameraX", "Show:Already")
            }
            else -> {
                result.launch(Manifest.permission.CAMERA)
            }
        }

    }
}

